"""
猜数字游戏
编写程序：输入一个程序，请用户反复输入一个猜测的数字，直到猜中了为止
"""
import random

target = random.randint(0, 1000)
count = 0
guess = 0
while guess != target:
    guess = int(input('请输入您猜测的数字:\n'))
    if guess > target:
        count += 1
        print('大了')
    elif guess < target:
        count += 1
        print('小了')
    else:
        count += 1
        print(f'猜对了,正确答案是{target},您猜了{count}次')
        break
